<template>
	<view class="px-3">
		<input class="uni-input" type="text" v-model="email" placeholder="输入邮箱地址"/>
		<input class="uni-input" type="text" v-model="password" placeholder="输入密码"/>
		<view class="px-2 py-3">
			<button class="bg-main text-white" style="border-radius: 50rpx;" type="primary"
			:disabled="disabled" :class="disabled ? 'bg-main-disabled' : ''"
			@click="submit"
			>提交邮箱</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				email: '',
				password: ''
			}
		},
		computed:{
			disabled() {
				return this.email == '' || this.password == ''
			}
		},
		methods: {
			check() {
				let rule = /^[A-Za-zd0-9]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$/
				if (!rule.test(this.email)) {
					uni.showToast({
						title:'邮箱格式不正确',
						icon:'none'
					})
					return false
				}
				return true
			},
			submit() {
				if (!this.check()) {
					return
				}
				console.log('提交邮箱成功')
			}
		}
	}
</script>

<style>
</style>
